<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    <div id="app" ref="changes">
        <button @click="readMode">阅读模式</button>
        <button @click="protedMode">护眼模式</button>
        <ul v-for="(item,index) in message" :key="index">
            <li>{{item.title}}</li>
            <li>{{item.content}}</li>
            <li>{{item.time}}</li>
        </ul>
    </div>
</body>
<script>
   const vm=new Vue({
        el: '#app',
        data: {
            message: "",
        },
        methods: {
            getText() {
                axios.get('https://v2.alapi.cn/api/joke', {
                    params: {
                        token: 'qSFjRCQtNKL2VpLz',
                    }
                }).then(response => {
                    console.log(response.data)
                    this.message = response.data.data;
                })
            },
            protedMode() {
                console.log(this)
                console.log(this.$refs.changes.style.backgroundColor="SeaGreen")
                console.log(vm.$refs.changes.style.color="white");
                
            },
            readMode(){
                console.log(this.$refs.changes.style.backgroundColor="SandyBrown")
                console.log(vm.$refs.changes.style.color="white");
            }

        },
        mounted() {
            this.getText();
        },
    })
</script>

</html>
